<?php

namespace app\queue\stomp;

use app\queue\BaseConsumer;
use common\service\TaskAssignService;
use think\Hook;

/**
 * 分配任务给部门 通知部门
 */
class SendAssignTaskToDepartmentNotifyConsumer extends BaseConsumer
{

    // 要消费的队列名
    public $queue = 'send_assign_task_to_department_notify';

    // 连接名，对应 config/redis_queue.php 里的连接`
    public $connection = 'default';

    /**
     * 任务排期
     * @param $data
     * @throws \Throwable
     */
    public function doConsume($data)
    {
        try {
            // 发送任务分配通知
            $hookData = [
                'type' => 'task_assign_to_department',
                'data' => $data,
            ];
            Hook::listen('task_assign', $hookData);
//            $taskAssignService = TaskAssignService::getInstance();
//            $taskAssignService->sendAssignTaskToDepartmentNotify($data['assign_user'], $data['assign_result']);
        } catch (\Throwable $e) {
            trace(format_exception_info($e), 'ERR');
        }
    }
}
